During the past 50 years, computer hardware, architecture, and operating systems that run on computers have evolved to provide ever-increasing storage space, execution speeds, and features that facilitate computer intercommunication, security, application-program development, and ever-expanding range of compatibilities and interfaces to other electronic devices, information-display devices, and information-storage devices. In the 1970's, enormous strides were made in increasing the capabilities and functionalities of operating systems, including the development and commercial deployment of virtual-memory techniques, and other virtualization techniques, that provide to application programs the illusion of extremely large address spaces and other virtual resources. Virtual memory mechanisms and methods provide 32-bit or 64-bit memory-address spaces to each of many user applications concurrently running on computer system with far less physical memory.
Virtual machine monitors provide a powerful new level of abstraction and virtualization. A virtual machine monitor comprises a set of routines that run directly on top of a computer machine interface, and that, in turn, provides a virtual machine interface to higher-level programs, such as operating systems. An operating system, referred to as a “guest operating system,” runs above, and interfaces to, a well-designed and well-constructed virtual-machine interface just as the operating system would run above, and interface to, a bare machine.
A virtual-machine monitor uses many different techniques for providing a virtual-machine interface, essentially the illusion of a machine interface to higher-level programs. A virtual-machine monitor may pre-process operating system code to replace privileged instructions and certain other instructions with patches that emulate these instructions. The virtual-machine monitor generally arranges to intercept and emulate the instructions and events which behave differently under virtualization, so that the virtual-machine monitor can provide virtual-machine behavior consistent with the virtual machine definition to higher-level software programs, such as guest operating systems and programs that run in program-execution environments provided by guest operating systems. The virtual-machine monitor controls physical machine resources in order to fairly allocate physical machine resources among concurrently executing operating systems and preserve certain physical machine resources, or portions of certain physical machine resources, for exclusive use by the virtual-machine monitor.
When a virtual-machine monitor emulates instruction, the virtual-machine monitor may need to introduce a multi-instruction patch routine that computes values not computed in the original code. In particular, the patch routine may need to access memory locations. In certain cases, the virtual-monitor needs to use additional registers, but, in certain machine architectures, there may be no registers that can be certain to be useable. Even storing register contents to memory to free a scratch register requires an available scratch register to contain the memory location, for example. Designers, implementers, manufacturers, and users of virtual-machine monitors and virtual-monitor-containing computer systems have recognized the need for a method by which virtual-machine monitors can obtain scratch registers for use during instruction emulation.